import  os
def inDomain():
    print("\t自动绑定域名的@、www、m、zc到官网上 agent到代理后台上")
    print("\t\t##########\t不要加www\t###########")
    domain=input("\t输入需要绑定的域名:")
    print('\t需要绑定的域名'+domain)
    return domain
def bingingDomain(domain):
    print('\t开始绑定@、m、zc、www')
    os.system("%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:XPJ_New_Offical_Py /+bindings.[protocol='http',bindingInformation='*:80:" + domain + "']")
    os.system("%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:XPJ_New_Offical_Py /+bindings.[protocol='http',bindingInformation='*:80:m." + domain + "']")
    os.system("%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:XPJ_New_Offical_Py /+bindings.[protocol='http',bindingInformation='*:80:zc." + domain + "']")
    res=os.system("%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:XPJ_New_Offical_Py /+bindings.[protocol='http',bindingInformation='*:80:www."+domain+"']")
    if res == 0:
        print("\t主要域名绑定成功")
    else:
        print("\t绑定失败")
        return 0
    print('\t开始绑定agent\t')
    res2=os.system("%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:XPJ_New_agentBackEnd_py /+bindings.[protocol='http',bindingInformation='*:80:agent."+domain+"']")
    if res2 == 0:
        print("\t主要域名绑定成功")
    else :
        print("\t绑定失败")
        return 0
if __name__ == '__main__':
    num=1
    #domain =None
    #num=num+1
    #domain=inDomain()
    #bingingDomain(domain)
    while True:
        num=num+1
        domain=inDomain()
        bingingDomain(domain)
        print("\n\n\n\n\n\n\n\t\t当前是第" + str(num) + "次增加域名")